#ifndef PROGRESSBAR_H
#define PROGRESSBAR_H

#include "sumHeader.h"



class ProgressPoint:public QWidget
{
    Q_OBJECT
public:
    ProgressPoint(QWidget *parent = nullptr);
    ~ProgressPoint();
    const constexpr static int Width = 20;
    const constexpr static int Height = 20;
signals:
    void moveX(int y);
private slots:
    void acceptMusicProgress(int x);
private:
    void mouseMoveEvent(QMouseEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
//    void mouseReleaseEvent(QMouseEvent *event) override;
    void paintEvent(QPaintEvent *event) override;
private:
    QPoint _lastMousePos;
    QPoint _orginPos;
};

class ProgressPointAndBar:public QWidget
{
    Q_OBJECT
public:
    ProgressPointAndBar(QWidget *parent = nullptr);
    ~ProgressPointAndBar();
    const constexpr static int Width = 344;
    const constexpr static int Height = 25;//14;
//public:
//    void Move(int x);
signals:
    void musicTimePoint(double rotia);
//    void sendPointCdMusic(double x);//x是横坐标增量
private slots:
    void moveBar(int x);
    void acceptCdMusicProgress(double ratio);
private:
    void paintEvent(QPaintEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
private:
    ProgressPoint *_pot;
    int _barMoveX;
};


class ProgressBar:public QWidget
{
    Q_OBJECT
public:
    ProgressBar(QWidget *parent = nullptr);
    ~ProgressBar();
    const constexpr static int ProgressBarHeight = 25;
private:
    void loadLayOut();
    void setText(double rotia);

private slots:
    void acceptMusicProgress(double rotia);//rotia是占比
    void acceptCdMusicProgress(double rotia);//rotia是比例
    void acceptMusicLength(double x);
//    void accceptResetBegin();
signals:
//    void musicTimePoint(double rotia);
    void sendPointAndBarCdMusicProgress(double x);
    void sendCdMusicProgress(double rotia);
    void sendVlcPlayerProgress(double);
private:
    QLabel *_leftTiming;
    QLabel *_rightTiming;
    ProgressPointAndBar *_dot;
    int _musicTimeSec = 0;
};

#endif // PROGRESSBAR_H
